package de.tum.in.eist.poll.shared.beans;
/**
 * Provided by the EIST team
 */

import java.io.Serializable;


/**
 * Representation of an abstract user.
 */
public abstract class User implements Serializable, Comparable<User> {
	
	/**
	 * serialization version
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * The user's unique name.
	 */
	private String userID;
	
	/**
	 * The user's password.
	 */
	private String password;
	
	/**
	 * Default zero-argument constructor.
	 */
	public User() {
		this("DummyUser","dummy");
	}
	
	/**
	 * @param userID {@link #userID}
	 * @param password {@link #password}
	 */
	public User(String userID, String password) {
		this.userID = userID;
		this.password = password;
	}
	
	/**
	 * @return the {@link #userID}.
	 */
	public String getUserID() {
		return userID;
	}
	
	/**
	 * @return the {@link #password}.
	 */
	public String getPassword() {
		return password;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((userID == null) ? 0 : userID.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		User other = (User) obj;
		if (userID == null) {
			if (other.userID != null)
				return false;
		} else if (!userID.equals(other.userID))
			return false;
		return true;
	}
	
	public int compareTo(User user) {
		return userID.compareTo(user.getUserID());
	}
}

